﻿using System;
using System.Linq;
using DZLib.ExtendFramework.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DZLib.ExtendFramework.UnitTests.Generic.ExtendIEnumerableTest
{
    [TestClass]
    public class ClipTest
    {
        [TestMethod]
        public void ClipNormTest()
        {
            var testCaseA = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
            var testCaseB = new int[] { 6, 7, 8 };
            var expected = new int[] { 1, 2, 3 };
            var actual = testCaseA.Clip(testCaseB).ToArray();
            Assert.IsTrue(expected.SequenceEqual(actual));
        }

        [TestMethod]
        public void ClipInverseTest()
        {
            var testCaseA = new int[] { 6, 7, 8 };
            var testCaseB = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
            var expected = new int[] { 6, 7, 8 };
            var actual = testCaseA.Clip(testCaseB).ToArray();
            Assert.IsTrue(expected.SequenceEqual(actual));
        }

        [TestMethod]
        public void ClipEmptyTest()
        {
            var testCaseA = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
            var testCaseB = new int[] { };
            var expected = new int[] { };
            var actual = testCaseA.Clip(testCaseB).ToArray();
            Assert.IsTrue(expected.SequenceEqual(actual));
        }

        [TestMethod]
        public void ClipEmptyInverseTest()
        {
            var testCaseA = new int[] { };
            var testCaseB = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
            var expected = new int[] { };
            var actual = testCaseA.Clip(testCaseB).ToArray();
            Assert.IsTrue(expected.SequenceEqual(actual));
        }

        [TestMethod]
        public void ClipEmptyDoubleTest()
        {
            var testCaseA = new int[] { };
            var testCaseB = new int[] { };
            var expected = new int[] { };
            var actual = testCaseA.Clip(testCaseB).ToArray();
            Assert.IsTrue(expected.SequenceEqual(actual));
        }
    }
}
